package com.taxshare.response.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

@Slf4j
public class PropertiesUtil {

    private PropertiesUtil() {
    }

    private static Properties props = null;

    static {
        try {
            Resource resource = new ClassPathResource("/framework-config/exception.code.properties");
            props = PropertiesLoaderUtils.loadProperties(new EncodedResource(resource, "UTF-8"));
        } catch (IOException e) {
            log.error("资源文件加载异常：{}", e);
        }
    }

    public static String getItem(String key) {
        return props.getProperty(key);
    }

}
